package com.example.flowerpcback.controller;

import com.example.flowerpcback.dto.Roles;
import com.example.flowerpcback.dto.RolesMenus;
import com.example.flowerpcback.req.RolesMenusReq;
import com.example.flowerpcback.req.RolesReq;
import com.example.flowerpcback.resp.CommonResp;
import com.example.flowerpcback.resp.PageResp;
import com.example.flowerpcback.resp.RolesMenusResp;
import com.example.flowerpcback.resp.RolesResp;
import com.example.flowerpcback.services.RoleService;
import com.example.flowerpcback.services.RolesMenusService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


@RestController //这是返回接口
@RequestMapping("/rolesMenus")
public class RoleMenusController {

    private static final Logger LOG = LoggerFactory.getLogger(RoleMenusController.class);

    @Resource
    private RolesMenusService rolesMenusService;

    @PostMapping("/save")
    public CommonResp<List<RolesMenus>> save(@Valid @RequestBody List<RolesMenusReq> req){
        CommonResp<List<RolesMenus>> resp= new CommonResp<>();
        List<RolesMenus> res = rolesMenusService.save(req);
        resp.setData(res);
        return  resp;
    }

    @GetMapping("/list")
    public CommonResp<List<RolesMenusResp> > list(@Valid RolesMenusReq req){
        CommonResp<List<RolesMenusResp>> resp= new CommonResp<>();
        List<RolesMenusResp>  res = rolesMenusService.list(req);
        resp.setData(res);
        return  resp;
    }
}

